//********************************************************************
//	created:	14:2:2012   17:46
//	filename: 	selectsocketmanager.h
//	author:		tiamo
//	purpose:	select socket manager
//********************************************************************

#pragma once

namespace network
{
	//
	// select
	//
	class SelectSocketManager : public SocketManager
	{
	public:
		//
		// constructor
		//
		SelectSocketManager(utils::Event& stopEv) : SocketManager(stopEv)	{mMaxOpenCount = FD_SETSIZE;}

		//
		// destructor
		//
		virtual ~SelectSocketManager()										{}

	private:
		//
		// poll network event
		//
		virtual void pollNetworkEvent(uint32_t pollTimeout);

		//
		// build select set
		//
		SOCKET buildSelectSet(fd_set& readSet, fd_set& writeSet, fd_set& errorSet);

		//
		// build event set
		//
		std::vector<std::pair<utils::SmartPointer<AsyncSocket>, int>> buildEventSet(fd_set& readSet, fd_set& writeSet, fd_set& errorSet);
	};
}
